package com.nuoniu.sibanyun.service.finance.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuoniu.sibanyun.entity.finance.InSubsidiary;
import com.nuoniu.sibanyun.mapper.finance.InSubsidiaryMapper;
import com.nuoniu.sibanyun.service.finance.IInSubsidiaryService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.apache.xmlbeans.impl.xb.xmlconfig.Usertypeconfig;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 存货明细账 服务实现类
 * </p>
 *
 * @author 小啊刚
 * @since 2021-05-26
 */
@Service
public class InSubsidiaryServiceImpl extends ServiceImpl<InSubsidiaryMapper, InSubsidiary> implements IInSubsidiaryService {

    @Override
    public Page<InSubsidiary> pageSubsidiaryList(Page page, Integer inventoryId, Integer accountYear, Integer accountPeriod) {
        QueryWrapper wrapper = new QueryWrapper();
        UserInfo userInfo = UserThreadLocal.get();
        wrapper.eq("company_id", userInfo.getCompanyId());
        wrapper.eq("account_year", accountYear);
        wrapper.eq("account_period", accountPeriod);
        if(inventoryId != null) {
            wrapper.eq("inventory_id", inventoryId);
        }

        return page(page, wrapper);
    }
}
